package com.yuan.java.reflect.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author yuaneg 2018/12/12
 */
public class MethodProxy implements InvocationHandler {

    private String methodName;

    private Object object;

    public MethodProxy(String methodName, Object object) {
        this.methodName = methodName;
        this.object = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if(methodName.equals(method.getName())){
            return "111";
        }
       return method.invoke(object,args);

    }
}
